from sqlmodel import SQLModel, Field
from datetime import datetime
from enum import Enum

class Side(str, Enum): 
    B = 'B' 
    S = 'S'

class Order(SQLModel, table=True):
    id: int | None = Field(default=None, primary_key=True)
    code: str
    side: Side
    price: float
    qty: int
    algo: str = Field(default='twap')          # twap / iceberg
    visible_size: int = 100                    # 冰山露出数量
    cancel_retry: int = 0                      # 已重试次数
    status: str = 'pending'     # pending/filled/cancelled
    created_at: datetime = Field(default_factory=datetime.utcnow)
